﻿Imports System
Imports System.ComponentModel
Imports System.Security
Imports System.Security.Permissions
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Imports System.ComponentModel.Design
Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Drawing.Design

<Assembly: TagPrefix("Lnc.Web.Social.Twitter.Scripts", "tws")> 
Namespace Twitter.Scripts

#Region "Controles"

    ''' <summary>
    ''' Script requerido por los controles Twitter para llamar a sus respectivos SDK
    ''' </summary>
    ''' <remarks>
    ''' Este script funciona con los controles del espacio de nombres Twitter.Javascript y Twitter.IFrame, 
    ''' los cuales son los widgets oficiales de Twitter
    ''' 
    ''' El equipo de LNC Producciones
    ''' </remarks>
    <Designer(GetType(TwitterScriptDesinger)), _
    Description("Script requerido por los controles Twitter para llamar a sus respectivos SDK"), _
    AspNetHostingPermission( _
    SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    AspNetHostingPermission( _
    SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    Utils.ToolboxTabName("LNC.WebControls"), _
    ToolboxData("<{0}:TwitterScript ID=""TwitterScript"" runat=""server""></{0}:TwitterScript>")> _
    <ToolboxBitmap(GetType(ResourceFinder), "TwitterScript.bmp")> _
    Public Class TwitterScript
        Inherits WebControl

        Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim s As String = ""
            s &= vbCrLf
            s &= "<!-- Twitter SDK : Inicio -->" & vbCrLf
            s &= "<!-- Codigo desarrollado por Nelson Ochoa -->" & vbCrLf
            s &= "<!-- Lnc.Web.Social Versión " & My.Application.Info.Version.ToString & " -->" & vbCrLf
            s &= "<script>" & vbCrLf
            s &= " !function(d,s,id){" & vbCrLf
            s &= "     var js,fjs = d.getElementsByTagName(s)[0];" & vbCrLf
            s &= "     if(!d.getElementById(id)) {" & vbCrLf
            s &= "         js = d.createElement(s);" & vbCrLf
            s &= "         js.id = id;" & vbCrLf
            s &= "         js.src = ""//platform.twitter.com/widgets.js"";" & vbCrLf
            s &= "         fjs.parentNode.insertBefore(js, fjs);" & vbCrLf
            s &= "     }" & vbCrLf
            s &= " }(document,""script"",""twitter-wjs"");" & vbCrLf
            s &= "</script>"
            s &= "<!-- Twitter SDK : Final -->" & vbCrLf
            writer.Write(s)
        End Sub

    End Class

#End Region

#Region "Diseñadores"

    Public Class TwitterScriptDesinger
        Inherits ControlDesigner

        Public Overrides Function GetDesignTimeHtml() As String
            Dim out As String = ""
            out = String.Format("<button style=""color: Black; background-color: #F7F7F7; font-size: 8pt;"">tws:<strong>TwitterScript</strong></button>")
            Return out
        End Function

    End Class

#End Region

End Namespace